package com.zyy.singleton;

import java.lang.reflect.Constructor;

/**
 * @Description: 枚举描述
 * @Author: zyy
 * @Date: 2023/07/19 00:13
 */
public enum EnumSingle {
    INSTANCE;

    // 单例类的其他方法
    public void someMethod() {
        // 方法实现
    }

    public static void main(String[] args) throws Exception {

        EnumSingle instance1 = EnumSingle.INSTANCE;

        Constructor<EnumSingle> declaredConstructor = EnumSingle.class.getDeclaredConstructor(String.class, int.class);
        declaredConstructor.setAccessible(true);
        //Cannot reflectively create enum objects
        EnumSingle instance2 = declaredConstructor.newInstance();

        System.out.println(instance1);
        System.out.println(instance2);
    }
}
